<?php
class Sales_details_model extends CI_Model {
    
    var $id = '';
    var $product_code = '';
    var $id_stock = '';
    var $id_purchase = '';
    var $mount = '';
    private $_tabla = 'sales_details';
    
    
   
    public function addDetails($data)
    {
        $this->db->insert($this->_tabla, $data);
    }
    
    public function search_sale_deatils($document_code){
       
        $query = $this->db->query("SELECT p.code,p.description, sd.box, sd.pack, sd.unit, p.price, sd.amount FROM products as p, sales_details as sd where p.code = sd.product_code and sd.document_code = '".$document_code."'");
        $rs = $query->result();
        return $rs;                      
    }
    
    public function delete_detail($document_code, $code){
       return $this->db->query("DELETE FROM sales_details WHERE  document_code='".$document_code."' AND product_code ='".$code."'");
    }
            
}